From a68af638f5d093ab93b92ea94fb7720752d782ad Mon Sep 17 00:00:00 2001 From: Shinjiman Date: Fri, 24 Jul 2009 18:35:09 +0000 Subject: [PATCH] fix E_NOTICE on r53720 and r53721. --- includes/GlobalFunctions.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 48638bd418..bf3c33f614 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3195,15 +3195,20 @@ function wfObjectToArray( $object, $recursive = true ) { function wfBCP47( $code ) { $codeSegment = explode( '-', $code ); foreach ( $codeSegment as $segNo => $seg ) { - // ISO 3166 country code - if ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) - $codeBCP[$segNo] = strtoupper ( $seg ); - // ISO 15924 script code - else if ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) - $codeBCP[$segNo] = ucfirst( $seg ); - // Keep casing for other cases - else + if ( count( $codeSegment ) > 0 ) { + // ISO 3166 country code + if ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) + $codeBCP[$segNo] = strtoupper ( $seg ); + // ISO 15924 script code + else if ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) + $codeBCP[$segNo] = ucfirst( $seg ); + else + // Keep casing for other cases + $codeBCP[$segNo] = $seg; + } else { + // Keep casing for single segment $codeBCP[$segNo] = $seg; + } } $langCode = implode ( '-' , $codeBCP ); return $langCode; -- 2.20.1